home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / mysql-4.0.22-win / data1.cab / Development / include / my_getopt.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-28  |  2.7 KB  |  72 lines

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.  
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.  
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16.  
  17. #ifndef _my_getopt_h
  18. #define _my_getopt_h
  19.  
  20. C_MODE_START
  21.  
  22. #define GET_NO_ARG     1
  23. #define GET_BOOL       2
  24. #define GET_INT        3
  25. #define GET_UINT       4
  26. #define GET_LONG       5
  27. #define GET_ULONG      6
  28. #define GET_LL         7
  29. #define GET_ULL        8
  30. #define GET_STR        9
  31. #define GET_STR_ALLOC 10
  32.  
  33. enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
  34.  
  35. struct my_option
  36. {
  37.   const char *name;                     /* Name of the option */
  38.   int        id;                        /* unique id or short option */
  39.   const char *comment;                  /* option comment, for autom. --help */
  40.   gptr       *value;                    /* The variable value */
  41.   gptr       *u_max_value;              /* The user def. max variable value */
  42.   const char **str_values;              /* Pointer to possible values */
  43.   ulong     var_type;
  44.   enum get_opt_arg_type arg_type;
  45.   longlong   def_value;                 /* Default value */
  46.   longlong   min_value;                 /* Min allowed value */
  47.   longlong   max_value;                 /* Max allowed value */
  48.   longlong   sub_size;                  /* Subtract this from given value */
  49.   long       block_size;                /* Value should be a mult. of this */
  50.   int        app_type;                  /* To be used by an application */
  51. };
  52.  
  53. typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * );
  54. typedef void (* my_error_reporter) (enum loglevel level, const char *format, ... );
  55.  
  56. extern char *disabled_my_option;
  57. extern my_bool my_getopt_print_errors;
  58. extern my_error_reporter my_getopt_error_reporter;
  59.  
  60. extern int handle_options (int *argc, char ***argv, 
  61.                const struct my_option *longopts, my_get_one_option);
  62. extern void my_print_help(const struct my_option *options);
  63. extern void my_print_variables(const struct my_option *options);
  64.  
  65. ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp);
  66. my_bool getopt_compare_strings(const char *s, const char *t, uint length);
  67.  
  68. C_MODE_END
  69.  
  70. #endif /* _my_getopt_h */
  71.  
  72.